package com.feicheng.controller.shop.admin.store;


import com.alibaba.fastjson.JSONObject;
import com.feicheng.common.constant.Constant;
import com.feicheng.common.result.ResultInfo;
import com.feicheng.service.impl.FStoreServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cailongyang
 * @since 2021-12-02
 */
@RestController("/shop/admin/store")
@RequestMapping("/shop/admin/store")
public class StoreController {
    @Autowired
    FStoreServiceImpl fStoreService;
    @GetMapping("/list")
    public ResultInfo getStoresByPage(String param,
                   @RequestParam(defaultValue = "1") Integer current,
                   @RequestParam (defaultValue = "10") Integer size){
        JSONObject result = JSONObject.parseObject(param);
        result.put(Constant.HTTP.PARAM.CURRENT, current);
        result.put(Constant.HTTP.PARAM.SIZE, size);
        return fStoreService.getStoresByPage(result);
    }

    @GetMapping("/info")
    public ResultInfo getStores(){
        return fStoreService.getStores(new JSONObject());
    }
    @GetMapping("/cha")
    public ResultInfo getStoreInfo(Integer storeId){
        return fStoreService.getStoreInfo(storeId);
    }

}
